package com.example.tms.mapper;

import com.example.tms.bean.FileInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface FileMapper extends JpaRepository<FileInfo, String> {

    //查询客户信息（所属id）
    @Query(value = "select * from file_info where ownerid = ?1", nativeQuery = true)
    List<FileInfo> findAll(String ownerid);

    //查询未提交文件
    List<FileInfo> findBySfcz(Boolean sfcz);

    //保存文件
    @Query(value = "update file_info set sfcz = true where fileid = ?1", nativeQuery = true)
    @Modifying
    @Transactional
    void updateCz(String fileid);
}
